package com.sms.web.system.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sms.common.BaseEntity;

/**
 * @desc 用户实体
 * @author WuJiangWu
 * @date 2018年7月23日下午11:45:56
 */
@Entity
@Table(name = "sys_user")
public class SysUser extends BaseEntity {
    
    private static final long serialVersionUID = -936203994181527906L;
    
    @Id
    @GeneratedValue(generator = "UIDGenerator")
    @GenericGenerator(name = "UIDGenerator", strategy = "com.sms.common.persistence.UIDGenerator")
    @Column(length = 40)
    private String id;
    
    /** 账号 */
    @NotNull(message = "账号不能为空")
    @NotBlank(message = "账号不能为空")
    @Column(length = 50, updatable = false)
    private String username;
    
    /** 用户昵称 */
    @NotNull(message = "用户姓名不能为空")
    @NotBlank(message = "用户姓名不能为空")
    @Column(length = 40)
    private String nickname;
    
    /** 用户头像 */
    @Column(length = 255, updatable = false)
    private String avatar;
    
    /** 邮箱 */
    @Column(length = 50)
    private String email;
    
    /** 电话 */
    @Column(length = 15)
    private String phone;
    
    /** 最后登陆日期 */
    @JsonIgnore
    private Date lastLoginDate;
    
    /**
     * 密码 ,密码已经设置为不能update，因为到数据的时候可能会被覆盖，要修改密码可以使用其他脚本方法。
     */
    @Column(length = 80, updatable = false, nullable = true)
	@JsonIgnore
    private String password;
    
    //==============================
    @Transient
    private List<SysMenu> menuList;
    @Transient
    private String token;
    //============================
    /**
     * 构造函数
     */
    public SysUser() {
    }
    
    /**
     * 构造函数
     */
    public SysUser(String id) {
        this.id = id;
    }
    
    
    public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public Date getLastLoginDate() {
        return lastLoginDate;
    }
    public void setLastLoginDate(Date lastLoginDate) {
        this.lastLoginDate = lastLoginDate;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public List<SysMenu> getMenuList() {
		return menuList;
	}
	public void setMenuList(List<SysMenu> menuList) {
		this.menuList = menuList;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getAvatar() {
		return avatar;
	}
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	
    
}
